package com.sherlocky.learning.java17.sealed.interfaces;

/**
 * sealed 与 record classes 使用
 */
public sealed interface Expr
    permits ConstantExpr, PlusExpr, TimesExpr, NegExpr {

}

record ConstantExpr(int i) implements Expr {

}

record PlusExpr(Expr a, Expr b) implements Expr {

}

record TimesExpr(Expr a, Expr b) implements Expr {

}

record NegExpr(Expr e) implements Expr {

}